<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>病案浏览历史</title>
</head>
<body>
<!--<div class="easyui-panel" data-options="fit:true,border:0"> -->
<div class="easyui-layout" data-options="fit:true,border:0">
	<div data-options="region:'north',split:false" class="north-min" style="border-left:0">
		   <span class="paddingTBL">
		      <div class="paddingB"> 
		            <label class="labelWid4">姓&nbsp;名&nbsp;</label>
					<input type="text" class="easyui-textbox" id="BroHistory_name" data-options="width:120,height:24"/>
		     	    <label class="paddingL30">出院科室&nbsp;</label>
					<input type="text" class="" id="BroHistory_fcydept" data-options="width:120,height:24"/>
			        <label class="paddingL30">出院日期&nbsp;</label>
					<input type="text" class="easyui-datebox" id="BroHistory_fcydate1" data-options="width:115,height:24"/>
					<label>&nbsp;至&nbsp;</label>
					<input type="text" class="easyui-datebox" id="BroHistory_fcydate2" data-options="width:115,height:24"/>
			    </div>
				<div class="paddingB"> 
				   <label>疾病类型&nbsp;</label>
				    <!-- <input type="text" class="" id="BroHistory_jbType" data-options="width:120,height:24"/> -->
				    <select class="easyui-combobox" id="BroHistory_jbType" data-options="width:120,height:24">
						<option value="0" selected="selected">全部诊断</option>
			            <option value="1">主要诊断</option>
			            <option value="2">其他诊断</option>
			            <option value="3">损伤中毒</option>
			    	</select>
			    	<label class="paddingL30">疾病名称&nbsp;</label>
				    <input type="text" class="easyui-textbox" id="BroHistory_jbName" data-options="width:120,height:24"/>
			    	<label class="labelWid4 paddingL30">病案号&nbsp;</label>
					<input class="easyui-searchbox" id="BroHistory_fprn" data-options="prompt:'条码号/住院号',width:262,height:24" />
			    </div>
				<div class="">
			    	<label class="">手术类型&nbsp;</label>
					<select class="easyui-combobox" id="BroHistory_operationType" data-options="width:120,height:24">
						<option value="0" selected="selected">全部手术</option>
			            <option value="1">主要手术</option>
			            <option value="2">其他手术</option>
			    	</select>  
				    <label class="paddingL30">手术名称&nbsp;</label>
				    <input type="text" class="easyui-textbox" id="BroHistory_opreationName" data-options="width:120,height:24"/>
				    <label class="paddingL30">主治医生&nbsp;</label>
					<input type="text" class="" id="BroHistory_fzzdoc" data-options="width:120,height:24"/>
			    	<span class="paddingL30"></span>
			    	<a href="#" class="easyui-linkbutton" onclick="queryHistory(time,mark)">检 索</a>
				</div> 
			</span>
		</div>
		
		<div data-options="region:'west'" style="width:20%;" class="Cancel_borderLB">
			<ul id="BroHistory_tree" ></ul>
		</div>
		<div data-options="region:'east'" style="width:80%;" class="Cancel_borderLB">
			<table id="BroHistoryGrid"></table>
		</div>
		
	<!-- 拍摄窗口  -->
	<div  id="BroHistoryDialog" class="easyui-dialog"  data-options="closed:true" style="width:100%;height:100%;">
		<!-- 该页面为公共浏览页，所以当不同的页面调用此页面时需给一个表示，通过此标识开放一定的权限 。2：表示浏览操作 -->
		<%-- <jsp:include page="../MedicalShootManage/Shoot.jsp" >
			<jsp:param value="2" name="tag"/>
			<jsp:param value="BroHistoryDialog" name="dialog"/>
		</jsp:include>	 --%>
		<!-- <div  class="easyui-panel" data-options="href:ctx+'/MedicalShootManage/Shoot?tag=2&dialog=BroHistoryDialog'" style="height: 100%;width:100%;"></div> -->
	</div>
	
	<!-- 申请窗口  -->
	<div  id="HisApplyDialog" class="easyui-dialog"  data-options="closed:true" style="width:450px;height:300px;">
		 <div class="paddingTBL">
			&nbsp;&nbsp;
			<label>病案号:&nbsp;</label><label class="shootFontBold broHistoryFprn"></label>&nbsp;&nbsp;
			<label>姓名:&nbsp;</label><label class="shootFontBold broHistoryFname"></label>&nbsp;&nbsp;
			<label>出院日期:&nbsp;</label><label class="shootFontBold broHistoryFcydate"></label>&nbsp;&nbsp;
		 
			 <div>
			    <p class="paddingB">
			   		 <label>申请目的&nbsp;</label><input type="text" class="easyui-textbox" id="" data-options="width:300,height:24"/></p>
				</p>
				<p class="paddingB">
					<label >浏览天数&nbsp;</label><input type="text" class="easyui-textbox" id="" data-options="width:95,height:24"/>
					<span class="paddingL"></span><label>截止日期&nbsp;</label><input type="text" class="easyui-datebox" id="" data-options="width:120,height:24"/>
				</p>
				<p>
				  <label class="labelWid4">备注&nbsp;</label><textarea id="BroHistory_mark" style="vertical-align: middle;resize:none;width:300px;height:50px;"></textarea>
				</p>
		    </div>
	    </div>
	</div>
</div> 
<!-- </div> -->

<script type="text/javascript">
//获取出院科室
$("#BroHistory_fcydept").combobox({
	url:ctx + "/MedicalShootManage/getDept",
	valueField:"ftykh",
	textField:"fksname",
	width:120, 
	height:24,
	onLoadSuccess : function() {
		$('#BroHistory_fcydept').combobox('select', 'TZYQY');
	}
});

//获取主治医生
$("#BroHistory_fzzdoc").combobox({
	url:ctx + "/MedicalShootManage/getZzDoc",
	valueField:"fzzdoctbh",
	textField:"fzzdoct",
	width:120, 
	height:24
});

var time = "";
var mark = ""; //标记当前为年份还是月份

//查询
function queryHistory(time,mark){
	var date1 = $("#BroHistory_fcydate1").datebox("getValue");
	var date2 = $("#BroHistory_fcydate2").datebox("getValue");
	var fcydept = $("#BroHistory_fcydept").combobox("getValue");
	var jbType = $("#BroHistory_jbType").combobox("getValue");
	var jbName = $("#BroHistory_jbName").textbox("getValue");
	var fzzDoc = $("#BroHistory_fzzdoc").combobox("getValue");
	var oType = $("#BroHistory_operationType").combobox("getValue");
	var oName = $("#BroHistory_opreationName").textbox("getValue");
	var fprn = $("#BroHistory_fprn").searchbox("getValue");
	var fname = $("#BroHistory_name").textbox("getValue");
	$("#BroHistoryGrid").datagrid({
		url:ctx + "/Archiving/queryBrowseHistory",
		queryParams:{
			"date1" : date1,
			"date2" : date2,
			"fcydept" : fcydept,
			"fzzDoc" : fzzDoc,
			"fprn" : fprn,
			"fname" : fname,
			"jbType" : jbType,
			"jbName" : jbName,
			"oType" : oType,
			"oName" : oName,
			"time" : time,
			"mark" : mark
			
		}
	});
}

//初始化表格
$("#BroHistoryGrid").datagrid({
		toolbar:"",
		fitColumns:false,
	    rownumbers:true,
		border : false,
		striped : true,
		fit : true,
		singleSelect: true,
		pagination : true,
		pageSize : 20,
		pageList : [ 20, 30,50 ],
		columns:[[
			{field:'operation',title:'操作',width:80,align:'center',
				formatter:function(value,row,index){
					if(row.fstatus == null || row.fstatus == ""){
						return "<a href='#' onclick='applyOperation("+index+")'>申请</a>";
					}else if(row.fstatus == "0"){
						return "<a href='#' onclick='applyOperation("+index+")'>申请</a>";
					}else if(row.fstatus == "1"){
						return "<a href='#' onclick='history_browse("+index+")'>浏览</a>";
					}
				}	
			},  
			{field:'fstatus',title:'状态',width:80,align:'center',
				formatter:function(value,row,index){
					if(value == null || value == ""){
						return "未翻拍";
					}else if(value == "0"){
						return "未翻拍";
					}else if(value == "1"){
						return "已翻拍";
					}
				}	
			},  
			{field:'',title:'浏览日期',width:100,align:'center',hidden:true},  
			{field:'fprn',title:'病案号',width:120,align:'center'},  
			{field:'fzyid',title:'住院ID',width:1,align:'center',hidden:true},  
			{field:'fcydate',title:'出院日期',width:100,align:'center',
				formatter:function(value){
					return new Date(value).format("yyyy-MM-dd");
				}	
			},  
			{field:'ftimes',title:'次数',width:50,align:'center'},  
			{field:'fname',title:'姓名',width:80,align:'center'},  
			{field:'fsex',title:'性别',width:50,align:'center'},  
			{field:'fage',title:'年龄',width:50,align:'center'},  
			{field:'fcydept',title:'出院科室',width:100,align:'center'},  
			{field:'fbarcode',title:'条码号',width:160,align:'center'},  
			{field:'frydate',title:'入院日期',width:100,align:'center',
				formatter:function(value){
					return new Date(value).format("yyyy-MM-dd");
				}		
			},  
			{field:'fzzdoct',title:'主治医生',width:100,align:'center'},  
			{field:'fjbname',title:'主要诊断',width:120,align:'center'},  
			{field:'fop',title:'主要手术',width:120,align:'center'}
			
		   ]]
	});
	
//加载树节点
$("#BroHistory_tree").tree({    
    url: ctx + "/Archiving/tree",  
    animate: false,
    checkbox:false,
    onSelect:function(node){
    	if(node.attributes == "all"){ //全部
    		time = "all";
    	}else if(node.attributes == "today") { //今天
    		time = "today";
    	}else if(node.attributes == "thisWeek"){ //本周
    		time = "thisWeek";
    	}else if(node.attributes == "lastWeek"){ //上周
    		time = "lastWeek";
    	}else if(node.attributes == "year"){ //年份
    		var text= node.text;
    		mark = text.substring(0,(text.length-1));
    		time = "year";
    	}else if(node.attributes == "month"){ //月份
    		var text = node.text;
    		mark = text.substring(0,(text.length-1));
    		//匹配数据库中的月份值
    		if(mark.length == 1){
    			mark = "0" + mark;
    		}
    		time = "month";
    	}
    	 queryHistory(time,mark); //查询数据
    }
});

//浏览图片
function history_browse(index){
	var rows = $("#BroHistoryGrid").datagrid("getRows")[index];
	$("#BroHistoryDialog").dialog({
		maximizable : true,
		closed : false,
		modal : true,
		href: ctx+'/MedicalShootManage/BrowsePage?tag=2&dialog=batchListDialog&fprn='+rows.fprn + '&fzyid=' +rows.fzyid 
			+ '&ftimes='+rows.ftimes+ '&fname='+encodeURI(encodeURI(rows.fname))+ '&fcydate='+new Date(rows.fcydate).format("yyyy-MM-dd")
			+ '&fbarcode='+rows.fbarcode,
		title : ''
	});
}

//打开申请窗口
function applyOperation(index){
	var items = $("#BroHistoryGrid").datagrid("getRows")[index];
	$("#HisApplyDialog").dialog({
		maximizable : true,
		closed : false,
		modal : true,
		title : '申请浏览病案',
		buttons : [ {
				text : '确认',
				iconCls : '',
				handler : function(){
					
				}
			}, {
				text : '取消',
				iconCls : '',
				handler : function() {
					$("#HisApplyDialog").dialog("close");
				}
			} ]
		});
	$(".broHistoryFprn").html(items.fprn);
	$(".broHistoryFname").html(items.fname);
	$(".broHistoryFcydate").html(new Date(items.fcydate).format("yyyy-MM-dd"));
	}
</script>  
</body>
</html>